#ifndef __CCLIENT_H__
#define __CCLIENT_H__
#include "cbuffer.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

class CClient{
public:

    CClient(int sockfd, int send_buffer_size, int recv_buffer_size);

    ~CClient();

    int recvdata();

    int senddata();

    int senddata(CBuffer * buffer);

    int senddata(const char * data, int size);

    bool has_send_data(){
        return m_send_buffer->has_data();
    }

    bool has_recv_data(){
        return m_recv_buffer->has_data();
    }

    int socket(){
        return m_sockfd;
    }

    CBuffer * send_buffer(){
        return m_send_buffer;
    }

    CBuffer * recv_buffer(){
        return m_recv_buffer;
    }

    char * ip(){
        return m_ip;
    }

    void ip(const char * ip){
        strcpy(m_ip, ip);
    }

    int port(){
        return m_port;
    }

    void port(int port){
        m_port = port;
    }
private:
    //持有的socket
    int m_sockfd = -1;
    //发送缓冲区
    CBuffer * m_send_buffer = nullptr;
    //接收缓冲区
    CBuffer * m_recv_buffer = nullptr;
    //ip
    char m_ip[16] = { 0 };
    //port
    int m_port = -1;
};

#endif
